package com.example.shkjdemo.test_recyclerview

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.shkjdemo.R
import com.example.shkjdemo.adapter.HorizonalTestAdapter
import com.example.shkjdemo.bean.HorizonalBean

class HorizontalRecyclerViewActivity : AppCompatActivity() {
    var mList: MutableList<HorizonalBean> = arrayListOf()
    lateinit var testrecycler: RecyclerView
    lateinit var adapter: HorizonalTestAdapter
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_horizontal_recycler_view)
        testrecycler = findViewById(R.id.testrecycler)
        initData()
        testrecycler.layoutManager =
            LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)

        adapter = HorizonalTestAdapter(mList)
        testrecycler.adapter = adapter
    }


    fun initData() {
        for (i in 1..10) {
            mList.add(HorizonalBean("项目${i}"))
        }
    }
}
